'''setting知识点'''

'''
1.setting后台中文配置:
LANGUAGE_CODE = 'zh-hans'

TIME_ZONE = 'Asia/Shanghai'

2.添加restframework 
    INSTALLED_APPS = [
    'rest_framework',
    ]
    

3. 允许域名限制
ALLOWED_HOSTS = ['*','www.tbzhu.com','*.com']

4.静态目录配置,模板引用需要在html头部{% load staticfiles %}

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
    os.path.join(BASE_DIR, 'templates'),
    os.path.join(BASE_DIR, 'app_User'),
    # os.path.join(BASE_DIR, 'media'),
)

5.restframework的配置,其中验证需要自己写,生成tokn和验证token可以用jwt(java web token)来写
解释器,只需要配置好就可以了

REST_FRAMEWORK = {
    # Use Django's standard `django.contrib.auth` permissions,
    # or allow read-only access for unauthenticated users.
    #添加验证,在vipUser应用里边,authenticatSet.py 文件内的Firstauthentication类
    'DEFAULT_AUTHENTICATION_CLASSES': ['app_User.utils.JWTdecode.JWTQueryParameAustentication',],
    #解释器
        'DEFAULT_PARSER_CLASSES':['rest_framework.parsers.JSONParser','rest_framework.parsers.FormParser','rest_framework.parsers.MultiPartParser'],
    # 'UNAUTHENTICATED_USER': lambda : '匿名用户',
    'UNAUTHENTICATED_USER': lambda : None,
    'UNAUTHENTICATED_TOKEN': lambda : None,
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
}

6.跨域csfrtoken
# 跨域增加忽略
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = ()

CORS_ALLOW_METHODS = (
    'DELETE',
    'GET',
    'OPTIONS',
    'PATCH',
    'POST',
    'PUT',
    'VIEW',
)

CORS_ALLOW_HEADERS = (
    'accept',
    'accept-encoding',
    'authorization',
    'content-type',
    'dnt',
    'origin',
    'user-agent',
    'x-csrftoken',
    'x-requested-with',
)
'''